#—*— codeing = utf-8 —*—
#@Time : 2022/9/15 20:57
#@Author :计科1813 38 和泽妮
#@File : 4.5.py
#@Software : PyCharm
import random

class Fish():
    def __init__(self):
        self.num = 10
        self.fishposition = []
        # 给10条鱼随机分配位置
        for i in range(10):
            self.fishposition.append([random.randint(0, 10), random.randint(0, 10)])

    def local(self):
        print("鱼的初始位置为:")
        for i in self.fishposition:
            print("(%d,%d)\n" % (i[0], i[1]))

    def move(self):
        for i in self.fishposition:
            if random.choice([0, 1]):
                if (i[0] == 10):
                    i[0] -= 1
                elif (i[0] == 0):
                    i[0] += 1
                else:
                    i[0] += random.choice([-1, 1])
            else:
                if (i[1] == 10):
                    i[1] -= 1
                elif (i[1] == 0):
                    i[1] += 1
                else:
                    i[1] += random.choice([-1, 1])
                    if i[1] < 0:
                        i[1] = 0 - i[1]
                    elif i[1] > 10:
                        i[1] = 10 - (10 - i[1])

    def now(self):
        print("鱼现在的位置为:", self.fishposition)
        print("鱼剩余数列量：", self.num)


class WUGUI():
    def __init__(self):
        self.tili = 100
        self.localx = random.randint(0, 10)
        self.localy = random.randint(0, 10)

    def local(self):
        print("乌龟的初始位置为：\n(%d,%d)\n" % (self.localx, self.localy))

    def move(self):
        if random.choice([0, 1]):    #0是x方向随机 y是z轴方向随机
            if(self.localx==10):
                self.localx-=1
            elif(self.localx==0):
                self.localx+=1
            else:
                    self.localx += random.choice([-2, -1, 1, 2])
                    if self.localx < 0:
                        self.localx = 0 - self.localx
                    elif self.localx > 10:
                        self.localx = 10 - (self.localx - 10)

        else:
            if (self.localy == 10):
                self.localx -= 1
            elif (self.localy == 0):
                self.localx += 1
            else:
                    self.localy += random.choice([-2, -1, 1, 2])
                    if self.localy <= 0:
                        self.localx = 0 - self.localx
                    elif self.localy >= 10:
                        self.localx = 10 - (self.localx - 10)
        self.tili -= 1

    def now(self):
        print("现在乌龟的位置为：\n(%d,%d)\n" % (self.localx, self.localy))
        print("乌龟剩余体力为：", self.tili)

def begin():
    wugui = WUGUI()
    fish = Fish()
    i = 1
    wugui.local()
    fish.local()
    while 1:
        print("-----------------------------------------------第%d步\n" % i)
        wugui.move()
        fish.move()
        wugui.now()
        fish.now()
        i += 1
        for each in fish.fishposition:
            if each[0] == wugui.localx and each[1] == wugui.localy:
                fish.num -= 1
                wugui.tili+=20
                fish.fishposition.remove(each)
            if wugui.tili <= 0:
                return "乌龟累死了！"
            if fish.num <= 0:
                return "乌龟家！"
print(begin())